home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / prog_disc / volume_4 / issue_07 / assembler / asmusing / readme < prev   
Encoding:
Text File  |  1991-03-16  |  2.9 KB  |  62 lines

  1.  
  2.        BASIC Function for Assembler Register Using/Drop   
  3.        ================================================
  4.                                                   (directory AsmUsing)
  5.  
  6. When writing assembler code it is much better to use variable names instead
  7. of register numbers.  This is a great aid to documentation, and gives some
  8. chance of understanding the code when the inevitable time comes to change
  9. it.
  10.  
  11. However, whether variable names or register numbers are used, it is often
  12. very difficult to keep track of which registers are being used for what.  It
  13. seems to be a fundamental law of computing that, however many registers you
  14. have, you always seem to need at least one more.  This inevitiably leads to
  15. using a register for several things, which in turn leads to using a register
  16. for two things at the same time.  This confuses the computer, and more so
  17. the programmer until the error is found!  This is a very common cause of
  18. strange errors in Assembler code which can be very difficult to find.
  19.  
  20. What is needed is for the assembler to keep track of register usage, but
  21. unfortunately it does not.  However, due to the brilliant integration with
  22. BASIC, it is fairly easy to add this facility. 
  23.  
  24. Three functions have been written, for inclusion within assembler source:
  25.  
  26. FNureg, which is inserted into the source code before it is required to use
  27. a particular register.  The register number, the variable name required, and
  28. a description of its use are passed as parameters.  If the register is
  29. already in use, a warning message is given.  The variable, which can be
  30. either an Integer or a Real variable, can then subsequently be used in the
  31. source code instead of the register number. 
  32.  
  33. FNdreg, which is used to drop a register when it's use for an item is
  34. complete.  The register number and its variable name are passed as
  35. parameters, and checked to ensure they are what is being used.  If the
  36. variable name is subsequently used, the assembler will error, as it will be
  37. set to -1.
  38.  
  39. FNlreg, which can be used at any time to display a list of registers in use,
  40. with their variable names and descriptions.
  41.  
  42. Two PROCedures have been defined also:
  43.  
  44. PROCireg, which is for initialisation.  It is for inclusion in the BASIC
  45. source, but within the FOR..NEXT loop for the assembly after opt has been
  46. set to the OPT value.  This procedure on the first pass of the assembler
  47. creates two arrays used to store the variable names and description, and
  48. uses PROCasmfindvar to assemble a small machine code routine.  It then
  49. initialises the arrays with any common register uses of your choice.
  50.  
  51. PROCasmfindvar assembles code to find the address and type of any BASIC
  52. variable, which may be of use for other purposes.  If the variable cannot be
  53. found, then one is created, unless it cannot be a variable name, when an
  54. error is raised.
  55.  
  56.  
  57. The sample program DemoUsing includes these facilities as a LIBRARY, and
  58. produces some warning messages when run.
  59.  
  60.  
  61.  
  62. Martin Avison